package com.tegtech.tools.aws.properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import lombok.Getter;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.regions.Region;

/**
 * aws配置
 * @Author Jun
 * @date 2021年4月28日 下午4:02:57
 */
@Component
public class AwsProperties {

	@Getter
	private static String accessId;
	
	@Getter
	private static String accessSecret;
	
	@Getter
	private static String s3Bucket;
	
	@Getter
	private static Long s3MaxContentLength;
	
	@Getter
	private static Long s3MaxPresignUrlDuration;
	
	@Getter
	private static String s3Host;
	
	@Getter
	private static String stsRoleArn;
	
	@Getter
	private static String stsSessionName;
	
	public static final Region s3Region = Region.US_EAST_1;
	
	public static AwsBasicCredentials awsBasicCredentials = AwsBasicCredentials.create(getAccessId(), getAccessSecret());

	@Value("${aws.access.id}")
	public void setAccessId(String accessId) {
		AwsProperties.accessId = accessId;
	}

	@Value("${aws.access.secret}")
	public void setAccessSecret(String accessSecret) {
		AwsProperties.accessSecret = accessSecret;
	}

	@Value("${aws.s3.bucket}")
	public void setS3Bucket(String s3Bucket) {
		AwsProperties.s3Bucket = s3Bucket;
	}

	@Value("${aws.s3.maxContentLength}")
	public void setS3MaxContentLength(Long s3MaxContentLength) {
		AwsProperties.s3MaxContentLength = s3MaxContentLength;
	}

	@Value("${aws.s3.maxPresignUrlDuration}")
	public void setS3MaxPresignUrlDuration(Long s3MaxPresignUrlDuration) {
		AwsProperties.s3MaxPresignUrlDuration = s3MaxPresignUrlDuration;
	}

	@Value("${aws.s3.host}")
	public void setS3Host(String s3Host) {
		AwsProperties.s3Host = s3Host;
	}

	@Value("${aws.sts.roleArn}")
	public void setStsRoleArn(String stsRoleArn) {
		AwsProperties.stsRoleArn = stsRoleArn;
	}

	@Value("${aws.sts.sessionName}")
	public void setStsSessionName(String stsSessionName) {
		AwsProperties.stsSessionName = stsSessionName;
	}
	
}
